.class public final Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;
.super Lio/reactivex/Single;
.source "ImportFileTask.kt"


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "Lio/reactivex/Single<",
        "Ljava/util/List<",
        "+",
        "Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;",
        ">;>;"
    }
.end annotation

.annotation system Ldalvik/annotation/SourceDebugExtension;
    value = "SMAP\nImportFileTask.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ImportFileTask.kt\nlt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,126:1\n1591#2,3:127\n*E\n*S KotlinDebug\n*F\n+ 1 ImportFileTask.kt\nlt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask\n*L\n116#1,3:127\n*E\n"
.end annotation


# instance fields
.field private final context:Landroid/content/Context;

.field private conversionTool:Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;

.field private final filePath:Ljava/lang/String;

.field private fileZipper:Llt/noframe/gpsfarmguide/import_fields/geoconvert/ShapeFileZipper;

.field private shapeFileHelper:Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;


# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/lang/String;)V
    .locals 1

    const-string v0, "context"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const-string v0, "filePath"

    invoke-static {p2, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 18
    invoke-direct {p0}, Lio/reactivex/Single;-><init>()V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->context:Landroid/content/Context;

    iput-object p2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->filePath:Ljava/lang/String;

    .line 20
    new-instance p1, Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;

    iget-object p2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->context:Landroid/content/Context;

    invoke-direct {p1, p2}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;-><init>(Landroid/content/Context;)V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->conversionTool:Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;

    .line 22
    new-instance p1, Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;

    invoke-direct {p1}, Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;-><init>()V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->shapeFileHelper:Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;

    .line 24
    new-instance p1, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ShapeFileZipper;

    invoke-direct {p1}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ShapeFileZipper;-><init>()V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->fileZipper:Llt/noframe/gpsfarmguide/import_fields/geoconvert/ShapeFileZipper;

    return-void
.end method


# virtual methods
.method public final convertShapeModelToFieldModel(Ljava/util/List;)Ljava/util/List;
    .locals 7
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List<",
            "Llt/farmis/libraries/shape_import_android/models/ShapeModel;",
            ">;)",
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;",
            ">;"
        }
    .end annotation

    const-string v0, "shapes"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 115
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    .line 128
    invoke-interface {p1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object p1

    const/4 v1, 0x0

    :goto_0
    invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_2

    invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    add-int/lit8 v3, v1, 0x1

    if-ltz v1, :cond_1

    check-cast v2, Llt/farmis/libraries/shape_import_android/models/ShapeModel;

    .line 117
    invoke-virtual {v2}, Llt/farmis/libraries/shape_import_android/models/ShapeModel;->getType()Llt/farmis/libraries/shape_import_android/ShapeImport$Shape;

    move-result-object v4

    sget-object v5, Llt/farmis/libraries/shape_import_android/ShapeImport$Shape;->POLYGON:Llt/farmis/libraries/shape_import_android/ShapeImport$Shape;

    if-ne v4, v5, :cond_0

    invoke-virtual {v2}, Llt/farmis/libraries/shape_import_android/models/ShapeModel;->getCoordinates()Ljava/util/List;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/List;->size()I

    move-result v4

    const/4 v5, 0x3

    if-lt v4, v5, :cond_0

    .line 118
    new-instance v4, Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;

    int-to-long v5, v1

    invoke-direct {v4, v5, v6, v2}, Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;-><init>(JLlt/farmis/libraries/shape_import_android/models/ShapeModel;)V

    .line 119
    invoke-interface {v0, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    :cond_0
    move v1, v3

    goto :goto_0

    .line 128
    :cond_1
    invoke-static {}, Lkotlin/collections/CollectionsKt;->throwIndexOverflow()V

    const/4 p1, 0x0

    throw p1

    :cond_2
    return-object v0
.end method

.method public final handleError(I)V
    .locals 2

    const/16 v0, 0x190

    if-eq p1, v0, :cond_1

    const/16 v0, 0x1a6

    if-eq p1, v0, :cond_0

    .line 109
    new-instance p1, Ljava/lang/RuntimeException;

    iget-object v0, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->context:Landroid/content/Context;

    const v1, 0x7f1100cc

    invoke-virtual {v0, v1}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v0

    invoke-direct {p1, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw p1

    .line 107
    :cond_0
    new-instance p1, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;

    invoke-direct {p1}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;-><init>()V

    throw p1

    .line 106
    :cond_1
    new-instance p1, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/NotSupportedFileFormatException;

    invoke-direct {p1}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/NotSupportedFileFormatException;-><init>()V

    throw p1
.end method

.method protected subscribeActual(Lio/reactivex/SingleObserver;)V
    .locals 13
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lio/reactivex/SingleObserver<",
            "-",
            "Ljava/util/List<",
            "Llt/noframe/gpsfarmguide/import_fields/imports/ImportFieldModel;",
            ">;>;)V"
        }
    .end annotation

    const-string v0, "improtFile.name"

    const-string v1, "observer"

    invoke-static {p1, v1}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 29
    :try_start_0
    new-instance v1, Ljava/io/File;

    iget-object v2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->filePath:Ljava/lang/String;

    invoke-direct {v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    const-string v2, "(?i).*\\.(kml)$"

    .line 31
    invoke-static {v2}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v2

    const-string v3, "(?i).*\\.(kmz)$"

    .line 32
    invoke-static {v3}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v3

    const-string v4, "(?i).*\\.(shp|shx|dbf)$"

    .line 33
    invoke-static {v4}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v4

    const-string v5, "(?i).*\\.(geojson|Geopackage|zip)$"

    .line 34
    invoke-static {v5}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v5

    .line 36
    invoke-virtual {v1}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v6

    invoke-static {v6, v0}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const-string v7, "patternKml"

    invoke-static {v2, v7}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    new-instance v7, Lkotlin/text/Regex;

    invoke-direct {v7, v2}, Lkotlin/text/Regex;-><init>(Ljava/util/regex/Pattern;)V

    invoke-virtual {v7, v6}, Lkotlin/text/Regex;->matches(Ljava/lang/CharSequence;)Z

    move-result v2

    const/4 v6, 0x0

    if-eqz v2, :cond_2

    .line 37
    iget-object v2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->shapeFileHelper:Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;

    sget-object v7, Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;->KML:Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;

    invoke-virtual {v2, v1, v7}, Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;->readFile(Ljava/io/File;Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;)Ljava/util/List;

    move-result-object v2

    if-eqz v2, :cond_1

    .line 39
    invoke-virtual {p0, v2}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->convertShapeModelToFieldModel(Ljava/util/List;)Ljava/util/List;

    move-result-object v2

    .line 40
    invoke-interface {v2}, Ljava/util/Collection;->isEmpty()Z

    move-result v7

    xor-int/lit8 v7, v7, 0x1

    if-eqz v7, :cond_0

    .line 41
    invoke-interface {p1, v2}, Lio/reactivex/SingleObserver;->onSuccess(Ljava/lang/Object;)V

    goto :goto_0

    .line 43
    :cond_0
    new-instance v2, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;

    invoke-direct {v2}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;-><init>()V

    invoke-interface {p1, v2}, Lio/reactivex/SingleObserver;->onError(Ljava/lang/Throwable;)V

    goto :goto_0

    .line 37
    :cond_1
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    throw v6

    .line 47
    :cond_2
    :goto_0
    :try_start_1
    invoke-virtual {v1}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2, v0}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const-string v7, "patternKmz"

    invoke-static {v3, v7}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    new-instance v7, Lkotlin/text/Regex;

    invoke-direct {v7, v3}, Lkotlin/text/Regex;-><init>(Ljava/util/regex/Pattern;)V

    invoke-virtual {v7, v2}, Lkotlin/text/Regex;->matches(Ljava/lang/CharSequence;)Z

    move-result v2

    if-eqz v2, :cond_5

    .line 48
    iget-object v2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->shapeFileHelper:Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;

    sget-object v3, Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;->KMZ:Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;

    invoke-virtual {v2, v1, v3}, Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;->readFile(Ljava/io/File;Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;)Ljava/util/List;

    move-result-object v2

    if-eqz v2, :cond_4

    .line 49
    invoke-virtual {p0, v2}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->convertShapeModelToFieldModel(Ljava/util/List;)Ljava/util/List;

    move-result-object v2

    .line 50
    invoke-interface {v2}, Ljava/util/Collection;->isEmpty()Z

    move-result v3

    xor-int/lit8 v3, v3, 0x1

    if-eqz v3, :cond_3

    .line 51
    invoke-interface {p1, v2}, Lio/reactivex/SingleObserver;->onSuccess(Ljava/lang/Object;)V

    goto :goto_1

    .line 53
    :cond_3
    new-instance v2, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;

    invoke-direct {v2}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;-><init>()V

    invoke-interface {p1, v2}, Lio/reactivex/SingleObserver;->onError(Ljava/lang/Throwable;)V

    goto :goto_1

    .line 48
    :cond_4
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    throw v6

    .line 57
    :cond_5
    :goto_1
    :try_start_2
    invoke-virtual {v1}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2, v0}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const-string v3, "patternShp"

    invoke-static {v4, v3}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    new-instance v3, Lkotlin/text/Regex;

    invoke-direct {v3, v4}, Lkotlin/text/Regex;-><init>(Ljava/util/regex/Pattern;)V

    invoke-virtual {v3, v2}, Lkotlin/text/Regex;->matches(Ljava/lang/CharSequence;)Z

    move-result v2
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0

    const-string v3, "response.body()!!"

    const-string v4, "cache.kml"

    const-string v7, "kml"

    const-string v8, "context.cacheDir"

    if-eqz v2, :cond_a

    .line 58
    :try_start_3
    iget-object v2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->fileZipper:Llt/noframe/gpsfarmguide/import_fields/geoconvert/ShapeFileZipper;

    iget-object v9, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->context:Landroid/content/Context;

    invoke-virtual {v9}, Landroid/content/Context;->getCacheDir()Ljava/io/File;

    move-result-object v9

    invoke-static {v9, v8}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    invoke-virtual {v2, v1, v9}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ShapeFileZipper;->getZip(Ljava/io/File;Ljava/io/File;)Ljava/io/File;

    move-result-object v2

    .line 60
    iget-object v9, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->conversionTool:Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;

    invoke-virtual {v9, v2, v7}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;->convert(Ljava/io/File;Ljava/lang/String;)Lretrofit2/Response;

    move-result-object v9

    .line 62
    invoke-virtual {v9}, Lretrofit2/Response;->isSuccessful()Z

    move-result v10

    if-eqz v10, :cond_9

    .line 63
    new-instance v10, Ljava/io/File;

    new-instance v11, Ljava/lang/StringBuilder;

    invoke-direct {v11}, Ljava/lang/StringBuilder;-><init>()V

    iget-object v12, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->context:Landroid/content/Context;

    invoke-virtual {v12}, Landroid/content/Context;->getCacheDir()Ljava/io/File;

    move-result-object v12

    invoke-static {v12, v8}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    invoke-virtual {v12}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v12

    invoke-virtual {v11, v12}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    sget-object v12, Ljava/io/File;->separator:Ljava/lang/String;

    invoke-virtual {v11, v12}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v11, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v11}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v11

    invoke-direct {v10, v11}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 64
    invoke-virtual {v10}, Ljava/io/File;->delete()Z

    .line 65
    invoke-virtual {v2}, Ljava/io/File;->delete()Z

    .line 66
    iget-object v2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->conversionTool:Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;

    invoke-virtual {v9}, Lretrofit2/Response;->body()Ljava/lang/Object;

    move-result-object v9

    if-eqz v9, :cond_8

    invoke-static {v9, v3}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    check-cast v9, Lokhttp3/ResponseBody;

    invoke-virtual {v2, v10, v9}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;->writeLocalFile(Ljava/io/File;Lokhttp3/ResponseBody;)V

    .line 68
    iget-object v2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->shapeFileHelper:Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;

    sget-object v9, Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;->KML:Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;

    invoke-virtual {v2, v10, v9}, Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;->readFile(Ljava/io/File;Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;)Ljava/util/List;

    move-result-object v2

    if-eqz v2, :cond_7

    .line 70
    invoke-virtual {p0, v2}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->convertShapeModelToFieldModel(Ljava/util/List;)Ljava/util/List;

    move-result-object v2

    .line 71
    invoke-interface {v2}, Ljava/util/Collection;->isEmpty()Z

    move-result v9

    xor-int/lit8 v9, v9, 0x1

    if-eqz v9, :cond_6

    .line 72
    invoke-interface {p1, v2}, Lio/reactivex/SingleObserver;->onSuccess(Ljava/lang/Object;)V

    goto :goto_2

    .line 74
    :cond_6
    new-instance v2, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;

    invoke-direct {v2}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;-><init>()V

    invoke-interface {p1, v2}, Lio/reactivex/SingleObserver;->onError(Ljava/lang/Throwable;)V

    goto :goto_2

    .line 68
    :cond_7
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_0

    throw v6

    .line 66
    :cond_8
    :try_start_4
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
    :try_end_4
    .catch Ljava/lang/Exception; {:try_start_4 .. :try_end_4} :catch_0

    throw v6

    .line 77
    :cond_9
    :try_start_5
    invoke-virtual {v9}, Lretrofit2/Response;->code()I

    move-result v0

    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->handleError(I)V
    :try_end_5
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_5} :catch_0

    throw v6

    .line 81
    :cond_a
    :goto_2
    :try_start_6
    invoke-virtual {v1}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2, v0}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    const-string v0, "patternOther"

    invoke-static {v5, v0}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    new-instance v0, Lkotlin/text/Regex;

    invoke-direct {v0, v5}, Lkotlin/text/Regex;-><init>(Ljava/util/regex/Pattern;)V

    invoke-virtual {v0, v2}, Lkotlin/text/Regex;->matches(Ljava/lang/CharSequence;)Z

    move-result v0

    if-eqz v0, :cond_f

    .line 82
    iget-object v0, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->conversionTool:Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;

    invoke-virtual {v0, v1, v7}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;->convert(Ljava/io/File;Ljava/lang/String;)Lretrofit2/Response;

    move-result-object v0

    .line 83
    invoke-virtual {v0}, Lretrofit2/Response;->isSuccessful()Z

    move-result v1

    if-eqz v1, :cond_e

    .line 84
    new-instance v1, Ljava/io/File;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    iget-object v5, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->context:Landroid/content/Context;

    invoke-virtual {v5}, Landroid/content/Context;->getCacheDir()Ljava/io/File;

    move-result-object v5

    invoke-static {v5, v8}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    invoke-virtual {v5}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v2, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    sget-object v5, Ljava/io/File;->separator:Ljava/lang/String;

    invoke-virtual {v2, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 85
    invoke-virtual {v1}, Ljava/io/File;->delete()Z

    .line 86
    iget-object v2, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->conversionTool:Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;

    invoke-virtual {v0}, Lretrofit2/Response;->body()Ljava/lang/Object;

    move-result-object v0

    if-eqz v0, :cond_d

    invoke-static {v0, v3}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    check-cast v0, Lokhttp3/ResponseBody;

    invoke-virtual {v2, v1, v0}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/GeoConvert;->writeLocalFile(Ljava/io/File;Lokhttp3/ResponseBody;)V

    .line 88
    iget-object v0, p0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->shapeFileHelper:Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;

    sget-object v2, Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;->KML:Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;

    invoke-virtual {v0, v1, v2}, Llt/farmis/libraries/shape_import_android/helpers/FileShapeHelper;->readFile(Ljava/io/File;Llt/farmis/libraries/shape_import_android/ShapeImport$FileType;)Ljava/util/List;

    move-result-object v0

    if-eqz v0, :cond_c

    .line 89
    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->convertShapeModelToFieldModel(Ljava/util/List;)Ljava/util/List;

    move-result-object v0

    .line 90
    invoke-interface {v0}, Ljava/util/Collection;->isEmpty()Z

    move-result v1

    xor-int/lit8 v1, v1, 0x1

    if-eqz v1, :cond_b

    .line 91
    invoke-interface {p1, v0}, Lio/reactivex/SingleObserver;->onSuccess(Ljava/lang/Object;)V

    goto :goto_3

    .line 93
    :cond_b
    new-instance v0, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;

    invoke-direct {v0}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/exceptions/UnprocessableFileException;-><init>()V

    invoke-interface {p1, v0}, Lio/reactivex/SingleObserver;->onError(Ljava/lang/Throwable;)V

    goto :goto_3

    .line 88
    :cond_c
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
    :try_end_6
    .catch Ljava/lang/Exception; {:try_start_6 .. :try_end_6} :catch_0

    throw v6

    .line 86
    :cond_d
    :try_start_7
    invoke-static {}, Lkotlin/jvm/internal/Intrinsics;->throwNpe()V
    :try_end_7
    .catch Ljava/lang/Exception; {:try_start_7 .. :try_end_7} :catch_0

    throw v6

    .line 96
    :cond_e
    :try_start_8
    invoke-virtual {v0}, Lretrofit2/Response;->code()I

    move-result v0

    invoke-virtual {p0, v0}, Llt/noframe/gpsfarmguide/import_fields/geoconvert/ImportFileTask;->handleError(I)V
    :try_end_8
    .catch Ljava/lang/Exception; {:try_start_8 .. :try_end_8} :catch_0

    throw v6

    :catch_0
    move-exception v0

    .line 100
    invoke-interface {p1, v0}, Lio/reactivex/SingleObserver;->onError(Ljava/lang/Throwable;)V

    :cond_f
    :goto_3
    return-void
.end method
